{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Prompt Length and Complexity Management\n",
    "\n",
    "## Overview\n",
    "\n",
    "This tutorial explores techniques for managing prompt length and complexity when working with large language models (LLMs). We'll focus on two key aspects: balancing detail and conciseness in prompts, and strategies for handling long contexts.\n",
    "\n",
    "## Motivation\n",
    "\n",
    "Effective prompt engineering often requires finding the right balance between providing enough context for the model to understand the task and keeping prompts concise for efficiency. Additionally, many real-world applications involve processing long documents or complex multi-step tasks, which can exceed the context window of LLMs. Learning to manage these challenges is crucial for building robust AI applications.\n",
    "\n",
    "## Key Components\n",
    "\n",
    "1. Balancing detail and conciseness in prompts\n",
    "2. Strategies for handling long contexts\n",
    "3. Practical examples using OpenAI's GPT model and LangChain\n",
    "\n",
    "## Method Details\n",
    "\n",
    "We'll start by examining techniques for crafting prompts that provide sufficient context without unnecessary verbosity. This includes using clear, concise language and leveraging prompt templates for consistency.\n",
    "\n",
    "Next, we'll explore strategies for handling long contexts, such as:\n",
    "- Chunking: Breaking long texts into smaller, manageable pieces\n",
    "- Summarization: Condensing long texts while retaining key information\n",
    "- Iterative processing: Handling complex tasks through multiple API calls\n",
    "\n",
    "Throughout the tutorial, we'll use practical examples to demonstrate these concepts, utilizing OpenAI's GPT model via the LangChain library.\n",
    "\n",
    "## Conclusion\n",
    "\n",
    "By the end of this tutorial, you'll have a solid understanding of how to manage prompt length and complexity effectively. These skills will enable you to create more efficient and robust AI applications, capable of handling a wide range of text processing tasks."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup\n",
    "\n",
    "First, let's import the necessary libraries and set up our environment."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Setup complete!\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from langchain_openai import ChatOpenAI\n",
    "from langchain.prompts import PromptTemplate\n",
    "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
    "from langchain.chains.summarize import load_summarize_chain\n",
    "\n",
    "# Load environment variables\n",
    "from dotenv import load_dotenv\n",
    "load_dotenv()\n",
    "\n",
    "# Set up OpenAI API key\n",
    "os.environ[\"OPENAI_API_KEY\"] = os.getenv('OPENAI_API_KEY')\n",
    "\n",
    "# Initialize the language model\n",
    "llm = ChatOpenAI(model=\"gpt-4o-mini\")\n",
    "\n",
    "print(\"Setup complete!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Balancing Detail and Conciseness\n",
    "\n",
    "Let's start by examining how to balance detail and conciseness in prompts. We'll compare responses from a detailed prompt and a concise prompt."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Detailed response:\n",
      "### Comprehensive Explanation of Artificial Intelligence\n",
      "\n",
      "#### Definition\n",
      "\n",
      "Artificial Intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think and learn like humans. It encompasses a range of technologies and methodologies that allow computers to perform tasks that typically require human intelligence, such as understanding natural language, recognizing patterns, solving problems, and making decisions.\n",
      "\n",
      "#### Historical Context\n",
      "\n",
      "The concept of AI dates back to ancient history, with myths and stories of automatons and intelligent beings. However, the formal study of AI began in the mid-20th century:\n",
      "\n",
      "1. **1950s - Birth of AI**: The term \"artificial intelligence\" was coined in 1956 during the Dartmouth Conference, organized by John McCarthy, Marvin Minsky, Nathaniel Rochester, and Claude Shannon. Early work focused on symbolic methods and problem-solving.\n",
      "\n",
      "2. **1960s - Early Programs**: Programs like ELIZA, which mimicked conversation, and SHRDLU, which understood natural language in a limited context, emerged.\n",
      "\n",
      "3. **1970s - The First AI Winter**: Progress slowed due to unmet expectations, leading to reduced funding and interest, known as the \"AI winter.\"\n",
      "\n",
      "4. **1980s - Revival through Expert Systems**: The development of expert systems, which used rule-based reasoning to solve specific problems, reignited interest.\n",
      "\n",
      "5. **1990s - Machine Learning**: The focus shifted towards machine learning, where computers learn from data. In 1997, IBM's Deep Blue defeated chess champion Garry Kasparov, marking a significant milestone.\n",
      "\n",
      "6. **2000s to Present - Deep Learning and Big Data**: Advances in computing power, availability of large datasets, and improvements in algorithms have led to the rise of deep learning. This era saw significant breakthroughs in computer vision, natural language processing, and reinforcement learning.\n",
      "\n",
      "#### Key Components\n",
      "\n",
      "1. **Machine Learning (ML)**: A subset of AI that enables systems to learn from data and improve over time without explicit programming. Techniques include supervised, unsupervised, and reinforcement learning.\n",
      "\n",
      "2. **Natural Language Processing (NLP)**: The ability of machines to understand, interpret, and respond to human language. Examples include chatbots, language translation, and sentiment analysis.\n",
      "\n",
      "3. **Computer Vision**: The capability to interpret and make decisions based on visual data from the world. Applications include facial recognition, autonomous vehicles, and medical image analysis.\n",
      "\n",
      "4. **Robotics**: The intersection of AI and robotics involves the creation of machines that can perform tasks autonomously. Examples include manufacturing robots and drones.\n",
      "\n",
      "5. **Expert Systems**: AI programs that emulate the decision-making ability of a human expert in a specific domain.\n",
      "\n",
      "#### Practical Applications\n",
      "\n",
      "AI has transformed various industries:\n",
      "\n",
      "- **Healthcare**: AI algorithms assist in diagnosing diseases, analyzing medical images, and personalizing treatment plans.\n",
      "- **Finance**: Fraud detection, algorithmic trading, and risk management are enhanced by AI systems.\n",
      "- **Transportation**: Self-driving cars and traffic management systems leverage AI to improve safety and efficiency.\n",
      "- **Retail**: AI is used for inventory management, personalized recommendations, and customer service chatbots.\n",
      "- **Entertainment**: Content recommendation systems in platforms like Netflix and Spotify use AI to tailor user experiences.\n",
      "\n",
      "#### Controversies and Debates\n",
      "\n",
      "1. **Ethical Concerns**: Issues related to privacy, surveillance, bias in AI algorithms, and the potential for job displacement raise ethical questions. For instance, biased algorithms can lead to discriminatory practices in hiring or law enforcement.\n",
      "\n",
      "2. **AI Safety**: The potential for AI systems to act unpredictably or harmfully has led to debates on how to ensure AI alignment with human values and safety.\n",
      "\n",
      "3. **Autonomous Weapons**: The development of AI in military applications raises concerns about accountability and the moral implications of autonomous weapons systems.\n",
      "\n",
      "4. **Regulation**: Governments and organizations are grappling with how to regulate AI technologies effectively while fostering innovation.\n",
      "\n",
      "#### Future Developments and Trends\n",
      "\n",
      "1. **Explainable AI (XAI)**: As AI systems become more complex, the need for transparency and interpretability in their decision-making processes is growing.\n",
      "\n",
      "2. **General AI**: Research continues into the development of Artificial General Intelligence (AGI), which would possess the ability to understand and learn any intellectual task that a human can.\n",
      "\n",
      "3. **Human-AI Collaboration**: Increasing focus on creating systems that enhance human capabilities rather than replace them.\n",
      "\n",
      "4. **AI in Sustainability**: Leveraging AI for climate modeling, resource management, and optimizing energy consumption.\n",
      "\n",
      "5. **Integration with IoT**: The convergence of AI with the Internet of Things (IoT) is expected to drive smarter devices and more efficient systems in various sectors.\n",
      "\n",
      "6. **Regulation and Policy Development**: As AI technologies evolve, there will likely be increased calls for regulatory frameworks to address ethical concerns and ensure responsible use.\n",
      "\n",
      "### Conclusion\n",
      "\n",
      "Artificial intelligence is a rapidly evolving field with profound implications for society. While it offers significant benefits across various domains, it also poses challenges that require careful consideration. As technology continues to advance, a balanced approach to innovation, ethics, and regulation will be essential in shaping the future of AI.\n",
      "\n",
      "Concise response:\n",
      "Artificial intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think and learn like humans. This encompasses a range of technologies, including machine learning, natural language processing, computer vision, and robotics, which enable computers to perform tasks that typically require human intelligence.\n",
      "\n",
      "The main importance of AI lies in its ability to enhance efficiency and productivity across various sectors. It can analyze vast amounts of data quickly, automate repetitive tasks, improve decision-making, and provide personalized experiences. AI applications are found in areas such as healthcare (diagnosing diseases), finance (fraud detection), transportation (autonomous vehicles), and customer service (chatbots), making processes more efficient and enabling innovations that can significantly improve quality of life.\n"
     ]
    }
   ],
   "source": [
    "# Detailed prompt\n",
    "detailed_prompt = PromptTemplate(\n",
    "    input_variables=[\"topic\"],\n",
    "    template=\"\"\"Please provide a comprehensive explanation of {topic}. Include its definition, \n",
    "    historical context, key components, practical applications, and any relevant examples. \n",
    "    Also, discuss any controversies or debates surrounding the topic, and mention potential \n",
    "    future developments or trends.\"\"\"\n",
    ")\n",
    "\n",
    "# Concise prompt\n",
    "concise_prompt = PromptTemplate(\n",
    "    input_variables=[\"topic\"],\n",
    "    template=\"Briefly explain {topic} and its main importance.\"\n",
    ")\n",
    "\n",
    "topic = \"artificial intelligence\"\n",
    "\n",
    "print(\"Detailed response:\")\n",
    "print(llm.invoke(detailed_prompt.format(topic=topic)).content)\n",
    "\n",
    "print(\"\\nConcise response:\")\n",
    "print(llm.invoke(concise_prompt.format(topic=topic)).content)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Analysis of Prompt Balance\n",
    "\n",
    "Let's analyze the differences between the detailed and concise prompts, and discuss strategies for finding the right balance."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "### Analysis of the Two Responses\n",
      "\n",
      "#### 1. Information Coverage\n",
      "- **Detailed Response**: This response provides a comprehensive overview of artificial intelligence. It includes definitions, historical context, key components, practical applications, relevant examples, controversies, and potential future developments. It covers a wide array of topics, making it suitable for readers looking for in-depth knowledge and understanding of AI.\n",
      "  \n",
      "- **Concise Response**: The concise response offers a brief definition of AI and highlights its importance and potential impacts. It touches on categories of AI and summarizes its applications in various industries. However, it lacks the depth provided in the detailed response, omitting historical context, specific examples, and discussions on controversies and future developments.\n",
      "\n",
      "#### 2. Clarity and Focus\n",
      "- **Detailed Response**: While the detailed response is rich in information, it may overwhelm some readers due to its extensive coverage. The organization into sections helps with clarity, but the sheer amount of information could lead to cognitive overload for those not familiar with the subject matter.\n",
      "\n",
      "- **Concise Response**: The concise response is clear and focused, delivering essential information in a straightforward manner. It effectively communicates the core concepts of AI without unnecessary complexity. However, it may leave readers wanting more detail, especially those who are unfamiliar with AI and its implications.\n",
      "\n",
      "#### 3. Potential Use Cases for Each Type of Response\n",
      "- **Detailed Response**: This response is suitable for:\n",
      "  - Academic settings or research purposes where an in-depth understanding of AI is required.\n",
      "  - Professionals in the AI field who need comprehensive knowledge of historical developments, technical specifics, and ethical considerations.\n",
      "  - Educational materials for teaching AI concepts at a higher level.\n",
      "\n",
      "- **Concise Response**: This response is ideal for:\n",
      "  - General audiences or newcomers seeking a quick overview of AI concepts.\n",
      "  - Business professionals looking for a high-level understanding of AI's impact on industries.\n",
      "  - Media articles or marketing materials that require succinct explanations without delving into technicalities.\n",
      "\n",
      "### Strategies for Balancing Detail and Conciseness in Prompts\n",
      "1. **Define the Audience**: Tailor the response based on the target audience's familiarity with the topic. For expert audiences, include more detailed information; for laypersons, stick to key concepts and applications.\n",
      "\n",
      "2. **Use Layered Information**: Start with a concise overview and then provide the option for deeper dives into specific sections. This could mean summarizing key points first, then linking to more detailed explanations for those interested.\n",
      "\n",
      "3. **Prioritize Key Points**: Identify and focus on the most critical aspects of the topic, eliminating less relevant details. Use bullet points or numbered lists for clarity and brevity.\n",
      "\n",
      "4. **Incorporate Visual Aids**: Use diagrams, flowcharts, or infographics to convey complex information visually, allowing for a clearer understanding without lengthy explanations.\n",
      "\n",
      "5. **Encourage Questions**: Invite readers to ask questions if they need clarification or more detail on specific points, creating a dynamic interaction that can address both detail and conciseness as needed.\n",
      "\n",
      "6. **Iterative Refinement**: Create initial drafts that include both concise and detailed sections, then refine the text based on feedback, focusing on clarity and essential information only.\n",
      "\n",
      "By applying these strategies, one can effectively balance the need for detailed information and the demand for conciseness in various contexts.\n"
     ]
    }
   ],
   "source": [
    "analysis_prompt = PromptTemplate(\n",
    "    input_variables=[\"detailed_response\", \"concise_response\"],\n",
    "    template=\"\"\"Compare the following two responses on artificial intelligence:\n",
    "\n",
    "Detailed response:\n",
    "{detailed_response}\n",
    "\n",
    "Concise response:\n",
    "{concise_response}\n",
    "\n",
    "Analyze the differences in terms of:\n",
    "1. Information coverage\n",
    "2. Clarity and focus\n",
    "3. Potential use cases for each type of response\n",
    "\n",
    "Then, suggest strategies for balancing detail and conciseness in prompts.\"\"\"\n",
    ")\n",
    "\n",
    "detailed_response = llm.invoke(detailed_prompt.format(topic=topic)).content\n",
    "concise_response = llm.invoke(concise_prompt.format(topic=topic)).content\n",
    "\n",
    "analysis = llm.invoke(analysis_prompt.format(\n",
    "    detailed_response=detailed_response,\n",
    "    concise_response=concise_response\n",
    ")).content\n",
    "\n",
    "print(analysis)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Strategies for Handling Long Contexts\n",
    "\n",
    "Now, let's explore strategies for handling long contexts, which often exceed the token limits of language models."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. Chunking\n",
    "\n",
    "Chunking involves breaking long texts into smaller, manageable pieces. Let's demonstrate this using a long text passage."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of chunks: 2\n",
      "First chunk: Artificial intelligence (AI) is a branch of computer science that aims to create intelligent machines that can simulate human cognitive processes.\n",
      "The field of AI has a rich history dating back to the...\n"
     ]
    }
   ],
   "source": [
    "# [A long passage about artificial intelligence, its history, applications, and future prospects...]\n",
    "\n",
    "long_text = \"\"\"\n",
    "Artificial intelligence (AI) is a branch of computer science that aims to create intelligent machines that can simulate human cognitive processes.\n",
    "The field of AI has a rich history dating back to the 1950s, with key milestones such as the development of the first neural networks and expert systems.\n",
    "AI encompasses a wide range of subfields, including machine learning, natural language processing, computer vision, and robotics.\n",
    "Practical applications of AI include speech recognition, image classification, autonomous vehicles, and medical diagnosis.\n",
    "AI has the potential to revolutionize many industries, from healthcare and finance to transportation and entertainment.\n",
    "However, there are ongoing debates and controversies surrounding AI, such as concerns about job displacement, bias in algorithms, and the ethical implications of autonomous systems.\n",
    "Looking ahead, the future of AI holds promise for advancements in areas like explainable AI, AI ethics, and human-AI collaboration. \n",
    "The intersection of AI with other technologies like blockchain, quantum computing, and biotechnology will likely shape the future of the field.\n",
    "But as AI continues to evolve, it is essential to consider the societal impact and ethical implications of these technologies.\n",
    "One of the key challenges for AI researchers and developers is to strike a balance between innovation and responsibility, ensuring that AI benefits society as \n",
    "a whole while minimizing potential risks.\n",
    "If managed effectively, AI has the potential to transform our world in ways we can only begin to imagine.\n",
    "Though the future of AI is uncertain, one thing is clear: the impact of artificial intelligence will be profound and far-reaching.\n",
    "\"\"\"\n",
    "\n",
    "# Initialize the text splitter\n",
    "text_splitter = RecursiveCharacterTextSplitter(\n",
    "    chunk_size=1000,\n",
    "    chunk_overlap=200,\n",
    "    length_function=len\n",
    ")\n",
    "\n",
    "# Split the text into chunks\n",
    "chunks = text_splitter.split_text(long_text)\n",
    "\n",
    "print(f\"Number of chunks: {len(chunks)}\")\n",
    "print(f\"First chunk: {chunks[0][:200]}...\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Summarization\n",
    "\n",
    "Summarization can be used to condense long texts while retaining key information. Let's use LangChain's summarization chain to demonstrate this."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\Users\\N7\\PycharmProjects\\llm_tasks\\prompt_engineering_private\\.venv\\Lib\\site-packages\\langchain_openai\\chat_models\\base.py:356: UserWarning: Unexpected type for token usage: <class 'NoneType'>\n",
      "  warnings.warn(f\"Unexpected type for token usage: {type(new_usage)}\")\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Summary:\n",
      "Artificial intelligence (AI), a field of computer science established in the 1950s, aims to create machines that replicate human cognitive processes. It encompasses areas like machine learning and natural language processing, with applications in speech recognition, autonomous vehicles, and medical diagnosis. While AI has transformative potential, it also raises concerns about job displacement, algorithmic bias, and ethical issues. Future advancements are expected in explainable AI, ethics, and human-AI collaboration, influenced by technologies like blockchain and quantum computing. Balancing innovation with responsibility is crucial to maximizing AI's benefits while minimizing risks, as its impact on society remains significant and uncertain.\n"
     ]
    }
   ],
   "source": [
    "from langchain.docstore.document import Document\n",
    "\n",
    "# Convert text chunks to Document objects\n",
    "doc_chunks = [Document(page_content=chunk) for chunk in chunks]\n",
    "\n",
    "# Load the summarization chain\n",
    "chain = load_summarize_chain(llm, chain_type=\"map_reduce\")\n",
    "\n",
    "# Summarize the long text\n",
    "summary_result = chain.invoke(doc_chunks)\n",
    "\n",
    "print(\"Summary:\")\n",
    "print(summary_result['output_text'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. Iterative Processing\n",
    "\n",
    "For complex tasks that require multiple steps, we can use iterative processing. Let's demonstrate this with a multi-step analysis task."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Final Analysis:\n",
      "The text provides a comprehensive overview of artificial intelligence (AI), covering its definition, historical development, various subfields, applications across different industries, and the associated challenges and ethical considerations. \n",
      "\n",
      "Key points include the identification of AI as a crucial domain within computer science aimed at mimicking human cognitive functions, alongside a historical timeline that traces its evolution since the 1950s. The text discusses significant subfields such as machine learning and natural language processing, while also detailing practical applications in areas like healthcare and transportation. \n",
      "\n",
      "Moreover, it addresses the societal implications of AI, including job displacement and algorithmic bias, emphasizing the need for ethical considerations in its development and deployment. The future prospects section highlights anticipated advancements and the integration of AI with emerging technologies, while acknowledging the uncertainties that lie ahead.\n",
      "\n",
      "**Conclusion**: The text effectively encapsulates the multifaceted nature of AI, underlining its transformative potential and the necessity for a balanced approach that considers both technological advancement and ethical responsibility. As AI continues to evolve, its implications for society will be profound, warranting ongoing dialogue and careful stewardship.\n"
     ]
    }
   ],
   "source": [
    "def iterative_analysis(text, steps):\n",
    "    \"\"\"\n",
    "    Perform iterative analysis on a given text.\n",
    "    \n",
    "    Args:\n",
    "    text (str): The text to analyze.\n",
    "    steps (list): List of analysis steps to perform.\n",
    "    \n",
    "    Returns:\n",
    "    str: The final analysis result.\n",
    "    \"\"\"\n",
    "    result = text\n",
    "    for step in steps:\n",
    "        prompt = PromptTemplate(\n",
    "            input_variables=[\"text\"],\n",
    "            template=f\"Analyze the following text. {step}\\n\\nText: {{text}}\\n\\nAnalysis:\"\n",
    "        )\n",
    "        result = llm.invoke(prompt.format(text=result)).content\n",
    "    return result\n",
    "\n",
    "analysis_steps = [\n",
    "    \"Identify the main topics discussed.\",\n",
    "    \"Summarize the key points for each topic.\",\n",
    "    \"Provide a brief conclusion based on the analysis.\"\n",
    "]\n",
    "\n",
    "final_analysis = iterative_analysis(long_text, analysis_steps)\n",
    "print(\"Final Analysis:\")\n",
    "print(final_analysis)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Practical Tips for Managing Prompt Length and Complexity\n",
    "\n",
    "Let's conclude with some practical tips for managing prompt length and complexity in real-world applications."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Here are five practical tips for developers working with large language models:\n",
      "\n",
      "1. **Break Down Tasks**: Divide complex queries into smaller, manageable tasks. This simplifies the prompt and allows the model to focus on specific aspects, improving accuracy and relevance.\n",
      "\n",
      "2. **Use Clear Instructions**: Formulate prompts with explicit and concise instructions. Clearly state what you want the model to do to minimize ambiguity and enhance performance.\n",
      "\n",
      "3. **Limit Context Length**: Keep the context provided to the model concise. Use only essential information to prevent overwhelming the model and to maintain focus on the primary task.\n",
      "\n",
      "4. **Iterate and Refine**: Test different prompt variations and analyze the outcomes. Iteratively refine your prompts based on model responses to achieve better results over time.\n",
      "\n",
      "5. **Leverage System Messages**: Utilize system messages to set the tone and style of responses. Providing clear guidelines at the start can help align the model's output with your expectations.\n"
     ]
    }
   ],
   "source": [
    "tips_prompt = \"\"\"\n",
    "Based on the examples and strategies we've explored for managing prompt length and complexity, \n",
    "provide a list of 5 practical tips for developers working with large language models. \n",
    "Each tip should be concise and actionable.\n",
    "\"\"\"\n",
    "\n",
    "tips = llm.invoke(tips_prompt).content\n",
    "print(tips)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
